package main

import (
	"fmt"
	"gitee.com/liuxueyang/gopl/ch7/database"
	"log"
	"net/http"
)

func main() {
	db := DB(database.Db)
	log.Fatal(http.ListenAndServe("localhost:8000", db))
}

type DB database.Database

func (db DB) ServeHTTP(
	w http.ResponseWriter,
	req *http.Request) {

	for item, price := range db {
		fmt.Fprintf(w, "%s: %s\n", item, price)
	}
}
